<template>
	<div class="list-page">
		<tool-bar nav="" title="短信消息">
			<el-button @click="add_click()">添加</el-button>
		</tool-bar>
		<my-list
			ref="list"
			url="/log/mobile-code-log/list"
			@param="preload"
			@loaded="procData"
			:page-size="10"
			:store="true"
		>


			<el-table-column align="center" label="模块" width="100" prop="module_res"></el-table-column>
			<el-table-column align="center" label="手机号" width="120" prop="mobile"></el-table-column>
			<el-table-column align="center" label="参数" width="180" prop="param"></el-table-column>
			<el-table-column align="center" label="结果">
				<template v-slot="scope">
					<div v-if="scope.row.result">{{ scope.row.result.code }}: {{ scope.row.result.description }}</div>
				</template>
			</el-table-column>
			<el-table-column align="center" label="错误" prop="errorMessage"></el-table-column>
			<el-table-column align="center" label="创建时间" width="160" prop="createAt"></el-table-column>


			<template #query="scope">
				<kv label="模块">
					<el-input v-model="scope.query.module"></el-input>
				</kv>
				<kv label="手机号">
					<el-input v-model="scope.query.mobile"></el-input>
				</kv>

				<kv label="结果">
					<el-input v-model="scope.query.result"></el-input>
				</kv>
				<kv label="错误消息">
					<el-input v-model="scope.query.errorMessage"></el-input>
				</kv>
			</template>
		</my-list>
	</div>
</template>

<script setup>
/**
 * Created by CodeGenerator at 2022-02-22 15:33:17
 */




//定义 vue2的this,当前组件
const $self = getCurrentInstance();

//定义 $attrs
const $attrs = useAttrs();



//定义data
const $data = reactive({
    MobileCodeModuleEnum: jv.enum.MobileCodeModuleEnum.getData()
});


const $props = defineProps({

});





const list = ref();

//定义事件
const $emit = defineEmits(["update:modelValue","loaded"]);



const preload = function(param) {
//添加查询参数，修改分页参数等。
//param.type = jv.$route.params.type
};
const procData = function(res) {
    res.data.data.forEach(it => {
//如果是组合实体，设置 it.id=...
        jv.enum.MobileCodeModuleEnum.fillRes(it, "module");
    });
};
const loadData = function(pageNumber) {
    list.value.loadData(pageNumber);
};
const add_click = function() {
    jv.$router.push("/log/mobile-code-log/add")
};
const edit_click = function(row) {
//记录上次点击行
    var rowId = row.id;
    list.value.setLastRow(row);
    jv.$router.push("/log/mobile-code-log/edit/" + rowId)
};
const delete_click = async function(row) {
    var rowId = row.id, rowName = row.name;
    await jv.confirm('确认删除 ' + rowName + ' 吗？');
    var res = await jv.$http.post("/log/mobile-code-log/delete/" + rowId)
    loadData();
};

</script>